package advanced;

import entity.Student;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/*
杨威
2021/9/7
14:33
*/
public class StudentRowMapper implements RowMapper<Student> {
    @Override
    public Student getRow(ResultSet resultSet) {
        Student student=null;
        try {
            int stuId = resultSet.getInt("stu_id");
            String stuName = resultSet.getString("stu_name");
            String stuGender = resultSet.getString("stu_gender");
            String stuPhone = resultSet.getString("stu_phone");
            Date bornDate = resultSet.getDate("bornDate");
            String stuEmail = resultSet.getString("stu_email");
            String stuAddress = resultSet.getString("stu_address");
            int gradeId = resultSet.getInt("grade_id");
            student=new Student();
            student.setStuId(stuId);
            student.setStuName(stuName);
            student.setStuGender(stuGender);
            student.setStuPhone(stuPhone);
            student.setBornDate(bornDate);
            student.setStuEmail(stuEmail);
            student.setStuAddress(stuAddress);
            student.setGradeId(gradeId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return student;
    }
}
